home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / misc / emu / p-interp.lha / p-interp-0.4 / UnitIo.c < prev    next >
C/C++ Source or Header  |  2001-06-09  |  3KB  |  175 lines

  1. /*
  2.  
  3.   P-Code interpreter (to run the apple pascal system)
  4.   Copyright (C) 2000 Mario Klebsch
  5.  
  6.   This program is free software; you can redistribute it and/or modify
  7.   it under the terms of the GNU General Public License as published by
  8.   the Free Software Foundation; either version 2 of the License, or
  9.   (at your option) any later version.
  10.  
  11.   This program is distributed in the hope that it will be useful,
  12.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.   GNU General Public License for more details.
  15.  
  16.   You should have received a copy of the GNU General Public License
  17.   along with this program; if not, write to the Free Software
  18.   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  
  20.   $Log: UnitIo.c,v $
  21.   Revision 1.5  2001/05/23 21:16:41  mario
  22.   Turtlegraphics wurde als eigener Prozess ausgelagert.
  23.  
  24.   Revision 1.4  2001/05/21 19:06:48  mario
  25.   Mode-Parameter bei den Disk-IO-Routinen entfernt
  26.  
  27.   Revision 1.3  2001/05/20 20:14:40  mario
  28.   Neues Gerät PRINTER: implementiert
  29.  
  30.   Revision 1.2  2001/05/20 13:12:02  mario
  31.   CVS-Idents und Logs eingefügt
  32.  
  33.  
  34. */
  35.  
  36. #ident "$Id: UnitIo.c,v 1.5 2001/05/23 21:16:41 mario Exp $";
  37.  
  38. #include <stdio.h>
  39.  
  40. #include "psystem.h"
  41. #include "Memory.h"
  42.  
  43. #include "Diskio.h"
  44. #include "Term.h"
  45.  
  46. void IoError(word Result)
  47. {
  48.   MemWr(IORSLT, Result);
  49. }
  50.  
  51. void UnitRead(word Unit, word Addr, Integer AddrOffset,
  52.           word Len, word Block, word Mode)
  53. {
  54.   IoError(0);
  55.   switch(Unit)
  56.     {
  57.     case 1:
  58.     case 2:
  59.       while (Len--)
  60.     {
  61.       char ch=TermRead();
  62.       if (Unit==1)
  63.         TermWrite(ch, 0);
  64.       MemWrByte(Addr, AddrOffset++, ch);
  65.     }
  66.       break;
  67.     case 4:
  68.     case 5:
  69.     case 9:
  70.     case 10:
  71.     case 11:
  72.     case 12:
  73.       DiskRead(Unit, Addr, AddrOffset, Len, Block);
  74.       break;
  75.     default:
  76.       IoError(2);
  77.       break;
  78.     }
  79. }
  80.  
  81. void PrinterWrite(byte ch, word Mode);
  82.  
  83. void UnitWrite(word Unit, word Addr, Integer AddrOffset,
  84.            word Len, word Block, word Mode)
  85. {
  86.   IoError(0);
  87.   switch(Unit)
  88.     {
  89.     case 1:
  90.     case 2:
  91.       while (Len--)
  92.     TermWrite(MemRdByte(Addr, AddrOffset++), Mode);
  93.       break;
  94.     case 4:
  95.     case 5:
  96.     case 9:
  97.     case 10:
  98.     case 11:
  99.     case 12:
  100.       DiskWrite(Unit, Addr, AddrOffset, Len, Block);
  101.       break;
  102.     case 6:
  103.       while (Len--)
  104.     PrinterWrite(MemRdByte(Addr, AddrOffset++), Mode);
  105.       break;
  106.     default:
  107.       IoError(2);
  108.       break;
  109.     }
  110. }
  111.  
  112. void PrinterClear(void);
  113. void GraphicsClear(void);
  114.  
  115. void UnitClear(word Unit)
  116. {
  117.   IoError(0);
  118.   switch(Unit)
  119.     {
  120.     case 1:
  121.     case 2:
  122.       break;
  123.     case 4:
  124.     case 5:
  125.     case 11:
  126.     case 12:
  127.       DiskClear(Unit);
  128.       break;
  129.     case 3:
  130.       PrinterClear();
  131. #ifdef TURTLEGRAPHICS
  132.       GraphicsClear();
  133. #endif
  134.       break;
  135.     case 6:
  136.       PrinterClear();
  137.       break;
  138.     default:
  139.       IoError(9);
  140.       break;
  141.     }
  142. }
  143.  
  144. void UnitStat(word Unit, word Addr, Integer Offset, word Dummy)
  145. {
  146.   IoError(0);
  147.   switch(Unit)
  148.     {
  149.     case 1:
  150.     case 2:
  151.       MemWr(Addr, TermStat());
  152.       break;
  153.     case 4:
  154.     case 5:
  155.     case 11:
  156.     case 12:
  157.       DiskStat(Unit);
  158.       break;
  159.     default:
  160.       IoError(9);
  161.       break;
  162.     }
  163. }
  164.  
  165. word UnitBusy(word Unit)
  166. {
  167.   IoError(0);
  168.   return(0);
  169. }
  170.  
  171. void UnitWait(word Unit)
  172. {
  173.   IoError(0);
  174. }
  175.